﻿using CPF.Controls;
using CPFUI.IControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPFUIDemo
{

    public class OfficeMenuHelper
    {
        public string ResourcesPath = "res://CPFUIDemo/Resources";
        public string StylePath = "res://CPFUIDemo/Style/css";
        public List<OfficeMenuModel> GetOfficeMenuList(string tabName)
        {
            List<OfficeMenuModel> list = new List<OfficeMenuModel>();
            if (tabName == "开始")
            {
                OfficeMenuModel model1 = new OfficeMenuModel() { Name = "插入" };
                model1.Items.Add(new OfficeMenuItem() { Name = "表格", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/1.png" });
                model1.Items.Add(new OfficeMenuItem() { Name = "", MenuType = OfficeMenuType.Split });
                model1.Items.Add(new OfficeMenuItem() { Name = "图片", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/2.png" });

                list.Add(model1);

                OfficeMenuModel model2 = new OfficeMenuModel() { Name = "页面" };
                model2.Items.Add(new OfficeMenuItem() { Name = "主题", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/3.png" });
                model2.Items.Add(new OfficeMenuItem() { Name = "水印", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/4.png" });

                list.Add(model2);


                OfficeMenuModel model3 = new OfficeMenuModel() { Name = "页面2" };
                model3.Items.Add(new OfficeMenuItem() { Name = "主题", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/5.png" });
                model3.Items.Add(new OfficeMenuItem() { Name = "水印", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/6.png" });

                list.Add(model3);
            }
            else if (tabName == "插入")
            {
                OfficeMenuModel model1 = new OfficeMenuModel() { Name = "插入" };
                model1.Items.Add(new OfficeMenuItem() { Name = "表格", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/1.png" });
                model1.Items.Add(new OfficeMenuItem() { Name = "", MenuType = OfficeMenuType.Split });
                model1.Items.Add(new OfficeMenuItem() { Name = "图片", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/2.png" });
                model1.Items.Add(new OfficeMenuItem() { Name = "形状", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/3.png" });
                model1.Items.Add(new OfficeMenuItem() { Name = "图标", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/4.png" });
                model1.Items.Add(new OfficeMenuItem() { Name = "文本框", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/5.png" });
                model1.Items.Add(new OfficeMenuItem() { Name = "艺术字", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/6.png" });
                list.Add(model1);
            }

            else if (tabName == "页面")
            {
                OfficeMenuModel model2 = new OfficeMenuModel() { Name = "页面" };
                model2.Items.Add(new OfficeMenuItem() { Name = "主题", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/1.png" });
                model2.Items.Add(new OfficeMenuItem() { Name = "水印", MenuType = OfficeMenuType.Button, Image = $"{ResourcesPath}/2.png" });

                list.Add(model2);
                OfficeMenuModel model5 = new OfficeMenuModel() { Name = "换肤", IsWrap = true, Width = 165 };
                model5.Items.Add(new OfficeMenuItem() { Name = "默认", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/3.png" });
                model5.Items.Add(new OfficeMenuItem() { Name = "护眼", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/4.png" });
                model5.Items.Add(new OfficeMenuItem() { Name = "暗黑", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/5.png" });
                model5.Items.Add(new OfficeMenuItem() { Name = "中国红", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/6.png" });
                model5.Items.Add(new OfficeMenuItem() { Name = "蓝色", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/7.png" });
                model5.Items.Add(new OfficeMenuItem() { Name = "紫色", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/8.png" });
                model5.Items.Add(new OfficeMenuItem() { Name = "金色", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/9.png" });
                model5.Items.Add(new OfficeMenuItem() { Name = "灰色", MenuType = OfficeMenuType.ListButton, Image = $"{ResourcesPath}/1.png" });

                list.Add(model5);
            }
            return list;
        }

        public CPF.Controls.MenuItem GetMenutem(string tabName, string image)
        {
            return new CPF.Controls.MenuItem
            {
                Header = tabName,

                Icon = new Picture
                {
                    Source = image,
                    Height = 18,
                    Width = 18,
                    Stretch = Stretch.Uniform,
                },
                Commands = {
                    {
                        "Click",
                        (s,e)=>{

                        ContextMenuItemClick(s,e as EventArgs);
                        }

                    }
                }
            };
        }

        private void ContextMenuItemClick(object sender, EventArgs e)
        {
            OnContextMenuItemClick?.Invoke(sender, e);
        }
        public event EventHandler<EventArgs> OnContextMenuItemClick;
    }
}
